package com.cloud.stock;

import cn.hutool.json.JSONUtil;
import com.cloud.controller.TestController;
import com.cloud.entity.Root;

import java.io.File;
import java.util.*;

/**
 * @author: create by God of SJF
 * @version: v1.0
 * @description: com.cloud.stock
 * @date:2021/9/17
 */
public class 分类5 {

    public static void main(String[] arg) throws Exception{
        File f = new File("/Users/libin/Desktop/分类3/");
        File[] files = f.listFiles();

        for (File thisFile : files) {
            System.out.println(thisFile.getName());
            File now = new File("/Users/libin/Desktop/分类3-1/"+thisFile.getName());
            Scanner scanner = new Scanner(thisFile);
            Set<String> set = new HashSet<>();
            while (scanner.hasNextLine()) {
                try {
                    String line = scanner.nextLine();
                    Root r = JSONUtil.toBean(line, Root.class);
                    String barcode = r.get_barcode_content();
                    String workId= r.get_workid();
                    String key = barcode +"-"+ workId;
                    if(!set.contains(key)){
                        List< String> list = new ArrayList<>();
                        list.add(line+"\r\n");
                        TestController.writeFile(now.getAbsolutePath(),list);
                        set.add(key);
                    }else {
                        System.out.println(key);
                    }
                }catch (Exception e) {
                    continue;
                }
            }
        }
    }
}
